#ifndef SWITCHES_H
#define SWITCHES_H


class Switches
{
	int m_numArgs;
	LPWSTR* m_args;
public:
	Switches(LPCWSTR str = ::GetCommandLineW())
		: m_numArgs(0)
		, m_args(CommandLineToArgvW(str, &m_numArgs))
	{}
	virtual ~Switches() { ::LocalFree(m_args); }

	bool IsSingleDllMode() const
	{	// is second param a dll?
		CString arg = GetNthArg(1); // get 2nd arg

		DWORD dw = ::GetFileAttributes(arg);
		if (dw == INVALID_FILE_ATTRIBUTES)
			return false; // usage problem
		return !(dw & FILE_ATTRIBUTE_DIRECTORY);
	}
	bool IsDumpMode() const
	{
		if (false == IsSingleDllMode())
			return false;

		CString arg = GetNthArg(2); // get 3rd arg
		return (arg == L"-?") || (arg == L"/?");
	}
	bool IsRecursiveMode() const
	{
		return !IsSingleDllMode();
	}

private:
	CString GetNthArg(int n) const
	{
		if (n >= m_numArgs || n < 0)
			return L"";
		return m_args[n];
	}
};

#endif
